/*
 * Created on 2005-8-28
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.store;

import com.jedi.BaseObj;
import com.jedi.KeyGen;
import com.tss.util.DbConn;
import com.tss.util.DbRs;
import com.tss.util.TSSDate;

/**
 * @author dai
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class ApproveExp extends BaseObj {
	public ApproveExp() {}
	public ApproveExp(String id) {this.listId = id;}
	public void insert() {
		clearErr();
		DbConn conn = new DbConn();
		try {
			String sql = "";
			setId(KeyGen.nextID(""));
			sql = "insert into t_approve_exp (" +
				" list_id,user_id,user_name,approve_val,author_id," +
				" author_name,project_id,appeal_cust,appeal_sales,exp_desc," +
				" exp_time) values (?,?,?,?,?,?,?,?,?,?,?)";
			conn.prepare(sql);
			conn.setString(1,getId());
			conn.setString(2,getUserId());
			conn.setString(3,getUserName());
			conn.setInt(4,getApproveVal());
			conn.setString(5,getAuthorId());
			conn.setString(6,getAuthorName());
			conn.setString(7,getProjectId());
			conn.setInt(8,getAppealCust());
			conn.setInt(9,getAppealSales());
			conn.setString(10,getExpDesc());
			conn.setString(11,TSSDate.fullTime());
			conn.executeUpdate();
		}
		catch(Exception ex) {
			ex.printStackTrace();
			setErr(ex.getMessage());
		}
		finally {
			conn.close();
		}
	}
	
	public void update() {
		clearErr();
		DbConn conn = new DbConn();
		try {
			if (getId().trim().equals("")) {
				setErr("û��Ҫ���µļ�¼ID��");
				return;
			}
			String sql = "update t_approve_exp set" +
				" user_id = ?,user_name = ?,approve_val = ?,author_id = ?,author_name = ?," +
				" project_id = ?, appeal_cust = ?,appeal_sales = ?,exp_desc = ?,exp_time = ?" +
				" where list_id = ?";
			conn.prepare(sql);
			conn.setString(1,getUserId());
			conn.setString(2,getUserName());
			conn.setInt(3,getApproveVal());
			conn.setString(4,getAuthorId());
			conn.setString(5,getAuthorName());
			conn.setString(6,getProjectId());
			conn.setInt(7,getAppealCust());
			conn.setInt(8,getAppealSales());
			conn.setString(9,getExpDesc());
			conn.setString(10,getExpTime());
			conn.setString(11,getId());
			conn.executeUpdate();
		}
		catch(Exception ex) {
			ex.printStackTrace();
			setErr(ex.getMessage());
		}
		finally {
			conn.close();
		}
	}
	
	public void delete() {
		clearErr();
		DbConn conn = new DbConn();
		DbRs rs = null;
		try {
			String sql = "";
			if (getId().trim().equals("")) {
				setErr("û��Ҫɾ��ļ�¼!");
				return;
			}
			sql = "delete from t_approve_exp where list_id = ?";
			conn.prepare(sql);
			conn.setString(1,getId());
			conn.executeUpdate();
		}
		catch(Exception ex) {
			ex.printStackTrace();
			setErr(ex.getMessage());
		}
		finally {
			conn.close();
		}
	}
	
	private void setId(String id) {this.listId = id;}
	public void setUserId(String userId) {this.userId = userId;}
	public void setUserName(String userName) {this.userName = userName;}
	
	public void setAuthorId(String authorId) {this.authorId = authorId;}
	public void setAuthorName(String authorName) {this.authorName = authorName;}
	public void setApproveVal(int approveVal) {this.approveVal = approveVal;}
	public void setProjectId(String projectId) {this.projectId = projectId;}
	public void setAppealCust(int appealCust) {this.appealCust = appealCust;}
	public void setAppealSales(int appealSales) {this.appealSales = appealSales;}
	public void setExpDesc(String expDesc) {this.expDesc = expDesc;}
	public void setExpTime(String expTime) {this.expTime = expTime;}

	public String getId() {return listId;}
	public String getUserId() {return userId;}
	public String getUserName() {return userName;}
	public int getApproveVal() {return approveVal;}
	public String getAuthorId() {return authorId;}
	public String getAuthorName() {return authorName;}
	public String getProjectId() {return projectId;}
	public int getAppealCust() {return appealCust;}
	public int getAppealSales() {return appealSales;}
	public String getExpDesc() {return expDesc;}
	public String getExpTime() {return expTime;}

	private String listId = "";
	private String userId = "";
	private String userName = "";
	private int approveVal = 0;
	private String authorId = "";
	private String authorName = "";
	private String projectId = "";
	private int appealCust = 0;
	private int appealSales= 0;
	private String expDesc = "";
	private String expTime = "";
	private String project_name="";//虚拟字段工单项目名称
	public String getProject_name() {
		return project_name;
	}
	public void setProject_name(String project_name) {
		this.project_name = project_name;
	}
}
